package com.cms.recursoshumanos.popup;

import com.cms.recursoshumanos.component.base.CustomButtonColored;
import com.cms.recursoshumanos.constant.Constant;
import com.cms.recursoshumanos.engine.ScreenEngine;
import com.cms.recursoshumanos.object.Ocio;

import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class EstablecimientoSelectorPopUp extends PopupScreen
{
    /**
     * Creates a new MyScreen object
     */
	//static Utileria tools = new Utileria();
	private CustomButtonColored boton_agregar_reservacion, 
								boton_consult_info;
	private Ocio elOcio;
	
	//public BeneficiosAdministrativosScreenHandler handler;
	
	public EstablecimientoSelectorPopUp(Ocio elOcio) 
	{
		super(new VerticalFieldManager() );
		this.elOcio = elOcio;
		setComponents();
	}
	protected boolean keyChar( char key, int status, int time )
    {
        if( key == Characters.ESCAPE ) {
           close();
           return false;
        }
        else
        {

            return true;
        }
    }
	public void setComponents() 
	{
        LabelField lbl_beneficio = new LabelField("Alternativa: "+elOcio.getNombreEstablecimientoOcio(), 
        												FIELD_HCENTER | DrawStyle.HCENTER);
		LabelField lbl_info_solicitud = new LabelField("Escoger una Opcion", FIELD_HCENTER | DrawStyle.HCENTER);
		
        Field separator = new SeparatorField();
        separator.setMargin( 6, 0, 6, 0 );
        VerticalFieldManager vfm = new VerticalFieldManager(FIELD_HCENTER | DrawStyle.HCENTER);
        
        boton_agregar_reservacion = new CustomButtonColored("Realizar una Reservacion",
				ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER | 
				USE_ALL_WIDTH | DrawStyle.HCENTER, 
				Constant.COLOR_BUTTON_FOCUS); 

        boton_agregar_reservacion.setChangeListener(new FieldChangeListener() 
        {
	   		public void fieldChanged(Field field, int context) 
	       	{ 
				close();
				ScreenEngine.getInstance().goSetReservacion(elOcio);
	       	} 
		}); 
        
        boton_consult_info = new CustomButtonColored("Ver el Establecimiento",
        												ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER  | 
        												USE_ALL_WIDTH | DrawStyle.HCENTER,
        												Constant.COLOR_BUTTON_FOCUS); 

        boton_consult_info.setChangeListener(new FieldChangeListener() 
        {
	   		public void fieldChanged(Field field, int context) 
	       	{ 
	   			close();
	   			ScreenEngine.getInstance().goDetailOcioScreen(elOcio);
	       	} 
		});
        
        add(lbl_beneficio);
        add(lbl_info_solicitud);
        add(separator);
       
        vfm.add( boton_agregar_reservacion );
        vfm.add( boton_consult_info );
        add(vfm);
        			
	}
	
	
}
